//
//  CYImageShowView.m
//  CreditAddressBook
//
//  Created by Mosu&Cuu on 16/5/30.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYImageShowView.h"
#import "CYHttpTool.h"
#import "CYJsonInfo.h"
#import "NSObject+MJKeyValue.h"
#import "MBProgressHUD+LE.h"
#import "CXCarouselView.h"
#import "CYUser.h"
#import "CYLoginHttpTool.h"
#import "LEPhotoBrowserTool.h"
#import "CYImageShowView.h"
#import "UIImageView+WebCache.h"

@interface CYImageShowView ()
@property (weak, nonatomic) IBOutlet UIView *imageView1;

@property (nonatomic,strong) NSString *imagestr1;
@property (nonatomic,strong) NSString *imagestr2;
@property (nonatomic,strong) NSString *imagestr3;
@property (nonatomic,strong) NSString *imagestr4;

@property (nonatomic, strong)NSArray *detailArr;


@end



@implementation CYImageShowView

- (void)viewDidLoad {
    [super viewDidLoad];
     [self setupZFBStatues];
    // Do any additional setup after loading the view from its nib.
}


-(void)setupZFBStatues{
     
     [CYHttpTool postWithURL:[CYURL shared].getZhifubao params:@{} success:^(id json) {
          CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
          NSDictionary *dic = jsoninfo.data;
          _detailArr = [dic objectForKey:@"pics"];
          // 屏幕的宽度 (也是承载imageView的view的宽度)
          CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
          // image各个边界的间隔
          CGFloat space = 10.f;
          // imageview的width (设定为x张)
          CGFloat imgWidth = screenWidth;
          // imageview的height
          CGFloat imgHeight = (_imageView1.height - space * 6 ) / _detailArr.count;
         
          for (int i = 0; i < _detailArr.count; i++ ) {
               // image的url string
               NSString *imgUrlString = [_detailArr objectAtIndex:i];
               // 创建imageView
               
               //space + (imgWidth + space) * i, space, imgWidth, imgHeight
               
               UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, space+(imgHeight+space)*i, imgWidth, imgHeight)];
               
               imgView.backgroundColor = [UIColor whiteColor];
               // 此处你可使用SDWebImage来加载
               [imgView sd_setImageWithURL:[NSURL URLWithString:imgUrlString]];
               [_imageView1 addSubview:imgView];
          }

     } failure:^(NSError *error) {
     
     }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
